<?php
/*ȡ*/

         include("json.php");
        if(isset($_COOKIE['LoginName'])){
          include("../funcs/funcs.php");
		  $conn=localConnectUsm();
          $output=array();
		  $id=intval($_GET['id']);
          $mp=$_COOKIE['Mobile'];
		  $sql="insert into orderuserinfotemp(mp,regtime,usesrvid,area,schoolcode,canceltime) select mp,regtime,usesrvid,area,schoolcode,getdate() from orderuserinfo where mp='$mp' and usesrvid='$id'";
		  $sql.=" delete from orderuserinfo where mp='$mp' and usesrvid='$id'";
		  switch($id){
                     case'1002':$sql.=" delete from orderpostuser where mp='$mp'";break;
                     case'1018':$sql.=" delete from SubSrvOrder where mp='$mp' and subsrvid<1044";break;//                     
                     default:break;
                 }
          $query=mssql_query($sql);
          $sql="select top 1 oprcode from PersonalBusiSync where mobile='".$mp."' order by id desc ";//ѯǷѾĶ
				$query=mssql_query($sql);
				$row=mssql_fetch_array($query);
				if($row['oprcode']=='01'){
				   $isorder=1;
				}
				else{
				   $isorder=0;
				}
           $sql="select usesrvid from orderuserinfo  where mp='".$mp."' ";//õжķ
              $query=mssql_query($sql);
              while($row=mssql_fetch_array($query)){
                    $data_id[]=$row['usesrvid'];

                   }
             $sql="select srvinfoid,servicename from serviceinfo";
             $query=mssql_query($sql);
			  while($row=mssql_fetch_array($query)){
					$servicename[$row['srvinfoid']]=iconv('gb2312','utf-8',$row['servicename']);
				}
		      if(count($data_id)>=1){
                         foreach($data_id as $id){
                           $data[]=$servicename[$id];
                         }

                       }
               $output['data']=$data;
               $output['isorder']=$isorder;
	       mssql_close();
           $json_encode=new Services_JSON();
          echo $json_encode->encode($output);
        }
        else{
              echo"δ¼";
             }

?>